﻿using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;

namespace Wips.AppService.Authorities.Users.Requests
{
    /// <summary>
    /// 更新个人设置请求类
    /// </summary>
    public class UpdateUserSettingRequest : IRequest<string>, ITxRequest
    {

        /// <summary>
        /// 真实姓名
        /// </summary>
        public string RealName { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string PhoneNumber { get; set; }

        /// <summary>
        /// 电子邮箱
        /// </summary>
        public string Email { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public class UpdateUserSettingValidator : AbstractValidator<UpdateUserSettingRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public UpdateUserSettingValidator()
        {
            RuleFor(p => p.PhoneNumber)
                .Must(p => !string.IsNullOrEmpty(p))
                .WithMessage("手机号不能为空")
                .MaximumLength(11)
                .WithMessage("手机号长度只能为11位");
        }
    }
}